<?php

namespace common\validate;


class ProjectMember extends BaseValidate
{
    // 验证规则
    protected $rule = [];

    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data.project_id', 'require')
            ->append('data.role_code', 'require|max:64')
            ->append('data.user_id', 'require');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.role_code', 'max:64');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require');
    }

    // BatchCreate 验证场景定义
    public function sceneBatchCreate()
    {
        return $this->append("data", "require")
            ->append("data.project_id", "require")
            ->append("data.user_list", "array");
    }

    // SingleCreate 验证场景定义
    public function sceneSingleCreate()
    {
        return $this->append("data", "require")
            ->append("data.project_id", "require")
            ->append("data.user_id", "require")
            ->append("data.role_code", "require");
    }

    // ScanExistDataToProjectMember 验证场景定义
    public function sceneScanExistDataToProjectMember()
    {
        return $this->append('param.project_id', 'require|integer');
    }

    public function sceneSyncUserRoleProjectMember()
    {
        return $this->append('data.tenant_id', 'require')
            ->append('data.role_code', 'require');
    }

    // RoleUserList 验证场景定义
    public function sceneRoleUserList()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    public function sceneManageList()
    {
        return $this->append('param.filter.type', 'in:production,manage');
    }
}
